package com.ruoyi.gis.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.gis.domain.WarnGisVo;
import com.ruoyi.gis.mapper.WarnGisMapper;
import com.ruoyi.gis.service.WarnGisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class WarnGisServiceImpl implements WarnGisService {

    @Autowired
    private WarnGisMapper warnGisMapper;

    @Override
    public List<Map<String, Object>> warnPointData(WarnGisVo vo) {
        List<Map<String, Object>> retList = new ArrayList<>();
        if (StringUtils.isNotEmpty(vo.getBeginTime()) && StringUtils.isNotEmpty(vo.getEndTime())) {
            vo.setBeginTime(vo.getBeginTime() + " 00:00:00");
            vo.setEndTime(vo.getEndTime() + " 23:59:59");
        } else {
            //默认近半个月
            vo.setBeginTime(DateUtils.dateFormat(DateUtils.addDays(new Date(), -15), "yyyy-MM-dd HH:mm:ss"));
            vo.setEndTime(DateUtils.dateFormat(new Date(), "yyyy-MM-dd HH:mm:ss"));
        }

        //断面
        List<Map<String,Object>> segmentWarnList=warnGisMapper.warnSegmentPointData(vo);
        //污染源预警
        List<Map<String,Object>> pollutionWarnList=warnGisMapper.warnPollutionPointData(vo);

        retList.addAll(segmentWarnList);
        retList.addAll(pollutionWarnList);
        return retList;
    }
}
